#!/bin/bash

# 疵点查询接口测试脚本
# 使用方法: ./test-flaw-api.sh

BASE_URL="http://localhost:8093/api/monitor"

echo "=== 疵点查询接口测试 ==="
echo ""

# 测试1: 根据机器ID和状态查询疵点详情
echo "1. 测试根据机器ID和状态查询疵点详情"
echo "请求: GET $BASE_URL/flaws?machineId=J001&cardStatus=1"
echo "响应:"
curl -s "$BASE_URL/flaws?machineId=J001&cardStatus=1" | jq '.' 2>/dev/null || curl -s "$BASE_URL/flaws?machineId=J001&cardStatus=1"
echo ""
echo ""

# 测试2: 根据机器ID查询当前正在生产的疵点详情
echo "2. 测试根据机器ID查询当前正在生产的疵点详情"
echo "请求: GET $BASE_URL/flaws/J001"
echo "响应:"
curl -s "$BASE_URL/flaws/J001" | jq '.' 2>/dev/null || curl -s "$BASE_URL/flaws/J001"
echo ""
echo ""

# 测试3: 测试不同的机器ID
echo "3. 测试不同的机器ID"
echo "请求: GET $BASE_URL/flaws?machineId=J002&cardStatus=1"
echo "响应:"
curl -s "$BASE_URL/flaws?machineId=J002&cardStatus=1" | jq '.' 2>/dev/null || curl -s "$BASE_URL/flaws?machineId=J002&cardStatus=1"
echo ""
echo ""

# 测试4: 测试不同的状态
echo "4. 测试不同的状态"
echo "请求: GET $BASE_URL/flaws?machineId=J001&cardStatus=0"
echo "响应:"
curl -s "$BASE_URL/flaws?machineId=J001&cardStatus=0" | jq '.' 2>/dev/null || curl -s "$BASE_URL/flaws?machineId=J001&cardStatus=0"
echo ""
echo ""

echo "=== 测试完成 ==="
echo ""
echo "接口说明:"
echo "- GET /api/monitor/flaws?machineId={machineId}&cardStatus={cardStatus}"
echo "  根据机器ID和状态查询疵点详情列表"
echo ""
echo "- GET /api/monitor/flaws/{machineId}"
echo "  根据机器ID查询当前正在生产的疵点详情列表"
echo ""
echo "返回字段说明:"
echo "- time: 疵点发生时间"
echo "- position: 疵点位置"
echo "- productId: 生产品ID"
echo "- cardId: 生产卡ID"
echo "- type: 疵点类型，0表示停车疵点，非0表示非停车疵点"
